package com.tarena.lbs.controller.api;


import com.tarena.lbs.service.QrCodeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/qrcode")
@Api(tags = "二维码生成接口")
public class QrCodeController {

    @Autowired
    private QrCodeService qrCodeService;

    @GetMapping(value = "/generate", produces = MediaType.IMAGE_PNG_VALUE)
    @ApiOperation(value = "生成二维码", notes = "根据内容和尺寸生成二维码图片")
    public byte[] generateQRCode(@RequestParam String content,
                                 @RequestParam(defaultValue = "200") int width,
                                 @RequestParam(defaultValue = "200") int height) {
        return qrCodeService.generateQRCode(content, width, height).getImageData();
    }
}
